package com.qf.springmvc2.controller;

import com.qf.springmvc2.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/json")
public class JsonController {

    @RequestMapping(value = "test1")
    public User test1(){
        User user = new User();
        user.setName("吴中洋");
        user.setPassword("1111");
        return user;
    }

    @GetMapping("test2")
    public User test2(){
        User user = new User();
        user.setName("吴中洋2");
        user.setPassword("1111");
        return user;
    }

    @GetMapping({"test3","test4"})
    public User test3(){
        User user = new User();
        user.setName("吴中洋34");
        user.setPassword("1111");
        return user;
    }

    @RequestMapping(value = "test5",produces = "text/html;charset=UTF-8")
    public String test5(){
        return "陈开心，天天开心";
    }

    @RequestMapping(value = "test6")
    public User test6(@RequestBody User user){
        System.out.println(user);
        return user;
    }
}
